package com.yanqu.road.entity.config.passroad;


import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 经商之路 每一条数据库记录
 */
public class PassRoadInfo {

	private int id;

	private String moneyListStr;

	private Map<Integer, Map<Integer, BigInteger>> moneyList;

	private String strengthListStr;

	private Map<Integer, Map<Integer,BigInteger>> strengthList;

	private String experienceStr;

	private Map<Integer, Map<Integer,BigInteger>> experience;

	private String prestigeStr;

	private Map<Integer, Map<Integer,BigInteger>> prestige;

	private String rewards;

	private String baseInspireConsume;

	private String eventsIdStr;

	private  Map<Integer,Integer> eventsId;

	private List<PassRoadPointInfo> passPointInfoList = new ArrayList<>();


	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getMoneyListStr() {
		return moneyListStr;
	}

	private Map<Integer, Map<Integer, BigInteger>> string2MapMap(String sourceStr){
		Map<Integer, Map<Integer, BigInteger>> data = new ConcurrentHashMap<>();
		List<String> moneyStrList = StringUtils.stringToStringList(sourceStr,"\\|");
		for(int i = 0; i < moneyStrList.size();i++){
			List<String> moneyList = StringUtils.stringToStringList(moneyStrList.get(i),";");
			Map<Integer, BigInteger> item = new ConcurrentHashMap<>();
			for(int j = 0; j < moneyList.size();j++){
				item.put(j,new BigInteger(moneyList.get(j)));
			}
			data.put(i,item);
		}
		return data;
	}

	public void setMoneyListStr(String moneyListStr) {
		this.moneyListStr = moneyListStr;
		this.moneyList = string2MapMap(moneyListStr);
	}

	public Map<Integer, Map<Integer, BigInteger>> getMoneyList() {
		return moneyList;
	}

	public String getStrengthListStr() {
		return strengthListStr;
	}

	public void setStrengthListStr(String strengthListStr) {
		this.strengthListStr = strengthListStr;
		this.strengthList = string2MapMap(strengthListStr);
	}

	public Map<Integer, Map<Integer, BigInteger>> getStrengthList() {
		return strengthList;
	}

	public String getExperienceStr() {
		return experienceStr;
	}

	public void setExperienceStr(String experienceStr) {
		this.experienceStr = experienceStr;
		this.experience = string2MapMap(experienceStr);
	}

	public Map<Integer, Map<Integer, BigInteger>> getExperience() {
		return experience;
	}

	public String getPrestigeStr() {
		return prestigeStr;
	}

	public void setPrestigeStr(String prestigeStr) {
		this.prestigeStr = prestigeStr;
		this.prestige = string2MapMap(prestigeStr);
	}

	public Map<Integer, Map<Integer, BigInteger>> getPrestige() {
		return prestige;
	}


	public String getRewards() {
		return rewards;
	}

	public void setRewards(String rewards) {
		this.rewards = rewards;
	}

	public String getBaseInspireConsume() {
		return baseInspireConsume;
	}

	public void setBaseInspireConsume(String baseInspireConsume) {
		this.baseInspireConsume = baseInspireConsume;
	}

	public String getEventsIdStr() {
		return eventsIdStr;
	}

	public void setEventsIdStr(String eventsIdStr) {
		this.eventsIdStr = eventsIdStr;
		Map<Integer, Integer> data = new ConcurrentHashMap<>();
		List<Integer> eventIdList = StringUtils.stringToIntegerList(eventsIdStr,"\\|");
		for(int i = 0;i < eventIdList.size();i++){
			data.put(i,eventIdList.get(i));
		}
		this.eventsId = data;
	}

	public Map<Integer, Integer> getEventsId() {
		return eventsId;
	}

	public void clearUsedLessObject() {
		moneyList = null;
		moneyListStr = null;

		strengthList = null;
		strengthListStr = null;

		experienceStr = null;
		experience = null;

		prestigeStr = null;
		prestige = null;

		eventsIdStr = null;
		eventsId = null;
	}

}
